<link rel="stylesheet" href="static/ui/css/bootstrap.min.css">
<link rel="stylesheet" href="static/ui/css/fileinput.css">
<script type="text/javascript" src="static/ui/js/fileinput.js"></script>
<script type="text/javascript" src="static/ui/js/fileinput_locale_zh.js"></script>
<script type="text/javascript" src="static/ui/js/bootstrap.min.js"></script>

<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 系统管理 <span class="c-gray en">&gt;</span> 用户管理<span class="c-gray en">&gt;</span> 添加用户</nav>
	<div id="sectionContent" class="Hui-article">
		<article class="page-container">
			<div class="form form-horizontal" id="form-admin-add">
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>头像：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<form enctype="multipart/form-data">
							<input id="headPortraitFile" type="file" multiple class="file" data-overwrite-initial="false" data-min-file-count="1">
            </form>
					</div>
				</div>
				<div class="row cl">
					<input type="hidden" id="headPortrait"/>
					<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>姓名：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="text" class="input-text" id="userName" name="userName">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>账号：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="text" class="input-text" id="account" name="account">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>初始密码：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="password" class="input-text" autocomplete="off" placeholder="密码" id="userPwd" name="userPwd">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>性别：</label>
					<div class="formControls col-xs-8 col-sm-9 skin-minimal">
						<div id="sex" class="radio-box">
							<input name="sex" type="radio" id="sex-1" checked value="MAN">
							<label for="sex-1">男</label>
						</div>
						<div class="radio-box">
							<input type="radio" id="sex-2" name="sex" value="WOMAN">
							<label for="sex-2">女</label>
						</div>
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>手机：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="text" class="input-text" id="phone" name="phone">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>邮箱：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="text" class="input-text" placeholder="@" name="email" id="email">
					</div>
				</div>
				<div class="row cl">
					<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
						<input class="btn btn-primary" type="button" v-on:click="saveData()" value="&nbsp;&nbsp;提交&nbsp;&nbsp;" style="margin-right:30px;">
						<input class="btn" type="button" onclick="javascript:history.go(-1)" value="&nbsp;&nbsp;取消&nbsp;&nbsp;">
					</div>
				</div>
			</div>
		</article>
	</div>
<script type="text/javascript">
  $("#headPortraitFile").fileinput({
        uploadUrl: '/restful/base/v1.0/commmon/upload',
        allowedFileExtensions : ['jpg', 'png','gif'],
        overwriteInitial: false,
        maxFileSize: 1000,
				language:'zh',
        maxFilesNum: 1,
				showCaption:false,
				showUpload:false,
				msgFilesTooMany : "选择上传的文件数量({n}) 超过允许的最大数值{m}！",
        //allowedFileTypes: ['image', 'video', 'flash'],
        slugCallback: function(filename) {
            return filename.replace('(', '_').replace(']', '_');
        }
	}).on("filebatchselected", function(event, files) {
      $(this).fileinput("upload");
  }).on("fileuploaded", function(event, result) {
      $('#headPortrait').val(result.response.data);
  });

</script>
<script>
    new Vue({
        el:'#sectionContent',
        http: authorization(),
        methods:{
            backToList:function(){
                window.parent.location.href="#!view/system/sub/subscriber-list.html?"+Math.random();
            },
            saveData:function(){
							var formData = {
									headPortrait:$('#headPortrait').val(),
									account:$('#account').val(),
									userName:$('#userName').val(),
									userPwd:$('#userPwd').val(),
									email:$('#email').val(),
									phone:$('#phone').val(),
									sex:$('#sex input[name="sex"]:checked ').val(),
							};
							this.$http.post('/restful/base/v1.0/subscriber',formData).then((response) => {
									this.backToList();
							}).catch(function(response) {
									alert(errorMsg(response));
							});
            }
        }
    });
</script>
